#include <iostream>
#include <list>
#include <vector>
//
// Created by lingzhitech on 25-9-24.
//
int main() {
    {
        std::vector<int> vec;
        std::list<int> lst{1, 3, 4, 5, 23};

        copy(lst.cbegin(), lst.cend(), std::back_inserter(vec));
        for (auto it = vec.cbegin(); it != vec.cend(); it++) {
            std::cout << *it << std::endl;
        }
    } {
        std::vector<int> vec;
        //reserve不会修改vec的大小
        vec.reserve(10); // reserve is covered in § 9.4 (p. 356)
        fill_n(std::back_inserter(vec), 10, 0);
        for (int num: vec) {
            std::cout << num << std::endl;
        }
    }
}